using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace TaugeLibrary.UserControls
{
    public class ExtendedTextBox:System.Windows.Forms.TextBox
    {
                    
        
        public ExtendedTextBox()
        {
            CharacterCasing = CharacterCasing.Upper;
        }

        protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                SendKeys.Send("{tab}");
                e.Handled = true;
            }            

            base.OnKeyDown(e);
            
            
            
        }


        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
                e.Handled = true;
            base.OnKeyPress(e);
        }

        //protected override void OnTextChanged(EventArgs e)
        //{
        //    if ((this.MaxLength > 0) && (this.SelectionStart == this.MaxLength))
        //    {
        //        SendKeys.Send("{tab}");
        //    }
        //    base.OnTextChanged(e);
        //}

        protected override void OnGotFocus(EventArgs e)
        {
            SelectionStart = 0;
            SelectionLength = Text.Length;
            
            base.OnGotFocus(e);
        }
        
    }
}
